<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        :root {
            --border-c: #409eff;
            --checked-c: #409eff;
            --size: 40px;
        }

        .switch {
            position: relative;
            display: block;
            height: var(--size);
            width: calc(var(--size) * 2);
            border-radius: 9999px;
            border: 1px solid var(--border-c);
            transition: background-color .6s .1s;
        }

        .switch:has(.switch__input:checked) {
            background-color: var(--checked-c);
        }

        .switch__input {
            position: absolute;
            inset: 0;
            opacity: 0;
        }

        .circle {
            position: absolute;
            top: 0;
            left: 0;
            height: var(--size);
            width: var(--size);
            border-radius: 50%;
            background-color: #fff;
            border: 1px solid var(--border-c);
            box-sizing: border-box;
            transition: transform .3s;
        }

        .switch__input:checked + .circle {
            transform: translateX(100%);
        }
    </style>
</head>

<body>
    <label class="switch">
        <input type="checkbox" class="switch__input" />
        <span class="circle"></span>
    </label>


    <script type="text/javascript">
        document.querySelector('.switch').onclick = function () {
            console.log(document.querySelector('.switch__input').checked)
        }
    </script>
</body>

</html>